class Logger{
  final String name;
  static final Map<String,Logger> _cache=<String,Logger>{};

  /**
   * 普通构造方法是不能return的
   * 工厂构造方法可以return 的
   */
  factory Logger(String name){
    if(_cache.containsKey(name)){
      return _cache[name];
    }else{
      final logger =Logger._internal(name);
      _cache[name]=logger;
      return logger;
    }
  }
  Logger._internal(this.name);  //私有化重载构造方法
  void log(String msg){
    print(msg);
  }
}